import { UserInfoData } from './../model/UserInfoData';
import { Component } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { StorageServic } from '../service/storage/storage.service';
@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss']
})
export class HomePage {
  public appPages = [
    {
      title: 'Register',
      url: '/register',
      icon: 'pricetags'
    },
    {
      title: 'List',
      url: '/home/list',
      icon: 'list'
    },
    {
      title: 'City',
      url: '/home/city',
      icon: 'locate'
    },
    {
      title: 'News',
      url: '/home/news',
      icon: 'paper'
    },{
      title:"AllPlan",
      url:'/home/all-plan',
      icon:'list'
    }
  ];
  userName: string = '点击登录';
  headUrl: string = 'assets/image/head_default.jpg';
  user: UserInfoData;
  constructor(private router: Router, private storage: StorageServic) {
    this.user = this.storage.read<UserInfoData>('userInfo');
    if (this.user) {
      this.userName = this.user.userName;
      this.headUrl = this.user.faceAbsoluteUrl;
    }
  }
  //登录
  onLogin() {
    if (!this.user) {
      this.router.navigateByUrl('/login');
    }
  }
}
